package org.luxor.eshop.payment.service;

import org.luxor.commons.core.web.data.R;
import org.luxor.eshop.payment.entity.dto.AccountDto;
import org.luxor.eshop.payment.entity.dto.PaymentReqDto;
import org.luxor.eshop.payment.entity.dto.ReceiptReqDto;
import org.luxor.eshop.payment.service.hystrix.AccountHystrixImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 远程RPC调用账户服务
 *
 * @author Mr.Yan  @date: 2020/9/2
 */
@FeignClient(name = "luxor-example-seata-account", path = "account", fallback = AccountHystrixImpl.class)
public interface AccountFeign {

    /**
     * 付款
     *
     * @param paymentReq 付款账号和额度
     * @return 付款成功？
     */
    @PostMapping(value = "/payment")
    R payment(@RequestBody PaymentReqDto paymentReq);

    /**
     * 收款
     *
     * @param receiptReq 收款账号和额度
     * @return 收款成功？
     */
    @PostMapping(value = "/receipt")
    R receipt(@RequestBody ReceiptReqDto receiptReq);

    /**
     * 获取账户信息
     *
     * @param account 账户编号
     * @return 账户信息
     */
    @GetMapping("/{account}")
    R<AccountDto> get(@PathVariable("account") String account);
}
